package com.bac.rentmap.web.controller.ad.user.view;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.bac.rentmap.ad.flat.user.view.ViewStatisticsManager;

public class IncViewStatisticsController extends AbstractController {
	private static final Logger log = Logger
			.getLogger(IncViewStatisticsController.class.getName());

	private ViewStatisticsManager viewStatisticsManager;

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Long flatAdId = Long.valueOf(request.getParameter("flatAdId"));
		log.fine("Inc view statistics for " + flatAdId);
		viewStatisticsManager.inc(flatAdId, 1);
		return null;
	}

	@Required
	public void setViewStatisticsManager(
			ViewStatisticsManager viewStatisticsManager) {
		this.viewStatisticsManager = viewStatisticsManager;
	}
}
